# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgbase=libretro-beetle-psx
pkgname=(
  libretro-beetle-psx
  libretro-beetle-psx-hw
)
pkgver=2666
pkgrel=1
pkgdesc='Sony PlayStation core'
arch=(loong64 x86_64)
url=https://github.com/libretro/beetle-psx-libretro
license=(GPL2)
groups=(libretro)
depends=(
  libretro-core-info
  zlib
)
makedepends=(
  git
  libglvnd
  mesa
  vulkan-icd-loader
)
_commit=6ed5790d058949dcc9f4ee02199f4a3e0d51e312
source=(libretro-beetle-psx::git+https://github.com/libretro/beetle-psx-libretro.git#commit=${_commit})
sha256sums=(SKIP)

pkgver() {
  cd libretro-beetle-psx

  git rev-list --count HEAD
}

prepare() {
  cp -r libretro-beetle-psx{,-hw}
}

build() {
  make \
    HAVE_LIGHTREC=1 \
    SYSTEM_LIBCHDR=0 \
    SYSTEM_ZLIB=1 \
    -C libretro-beetle-psx
  make \
    HAVE_HW=1 \
    HAVE_LIGHTREC=1 \
    SYSTEM_LIBCHDR=0 \
    SYSTEM_ZLIB=1 \
    -C libretro-beetle-psx-hw
}

package_libretro-beetle-psx() {
  install -Dm 644 libretro-beetle-psx/mednafen_psx_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

package_libretro-beetle-psx-hw() {
  depends+=(libgl)

  install -Dm 644 libretro-beetle-psx-hw/mednafen_psx_hw_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
